/**
Nectarine Utility Project is a software interface for the web system 'demovibes'
Copyright (C) 2010  Alexandre LAURENT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

website: http://code.google.com/p/nectarine-utility-project/
e-mail: lw.demoscene@gmail.com
**/

#include "webutils.h"

#include <QString>
#include <QNetworkReply>

const QString WebUtils :: parseWebError(const QNetworkReply::NetworkError errorCode)
{
    switch (errorCode)
    {
    case QNetworkReply::NoError:
        return QString("No error");
        break;
    case QNetworkReply::ConnectionRefusedError:
        return QString("The server refused to be reached");
        break;
    case QNetworkReply::RemoteHostClosedError:
        return QString("Connection closed prematurely");
        break;
    case QNetworkReply::HostNotFoundError:
        return QString("The website was not found, please check your internet connectivity");
        break;
    case QNetworkReply::TimeoutError:
        return QString("Time out");
        break;
    case QNetworkReply::OperationCanceledError:
        return QString("Connection cancelled");
        break;
    case QNetworkReply::SslHandshakeFailedError:
        return QString("SSL connection failed");
        break;
    case QNetworkReply::ProxyConnectionRefusedError:
        return QString("Connection to the proxy server refused");
        break;
    case QNetworkReply::ProxyConnectionClosedError:
        return QString("COnnection to the proxy closed prematurely");
        break;
    case QNetworkReply::ProxyNotFoundError:
        return QString("Proxy server not found");
        break;
    case QNetworkReply::ProxyTimeoutError:
        return QString("Proy time out");
        break;
    case QNetworkReply::ProxyAuthenticationRequiredError:
        return QString("Proxy authentification failed");
        break;
    case QNetworkReply::ContentAccessDenied:
        return QString("Access denied '401'");
        break;
    case QNetworkReply::ContentOperationNotPermittedError:
        return QString("Operation not permitted");
        break;
    case QNetworkReply::ContentNotFoundError:
        return QString("Content not found '404'");
        break;
    case QNetworkReply::AuthenticationRequiredError:
        return QString("Server need authentification");
        break;
    case QNetworkReply::ContentReSendError:
        return QString("Failed to resend data");
        break;
    case QNetworkReply::ProtocolUnknownError:
        return QString("Protocol unknown");
        break;
    case QNetworkReply::ProtocolInvalidOperationError:
        return QString("The operation is not valid for this protocol");
        break;
    case QNetworkReply::UnknownNetworkError:
        return QString("Unknown network error");
        break;
    case QNetworkReply::UnknownProxyError:
        return QString("Unknown proxy error");
        break;
    case QNetworkReply::UnknownContentError:
        return QString("Unknown content error");
        break;
    case QNetworkReply::ProtocolFailure:
        return QString("Undetermined error in the protocol");
        break;
    default:
        return QString("Error not handled");
    }

    return QString("");
}
